import 'dart:ui';

import 'package:color_dart/RgbaColor.dart';
import 'package:flutter/material.dart';
import 'package:im_flutter_sdk_example/pages/toolbar/alliance/widgets/head.dart';
import 'package:im_flutter_sdk_example/pages/toolbar/alliance/widgets/homepage.dart';
import 'package:im_flutter_sdk_example/pages/toolbar/alliance/widgets/project_expert.dart';
import 'package:im_flutter_sdk_example/pages/toolbar/alliance/widgets/tabBtn.dart';
import 'package:im_flutter_sdk_example/pages/toolbar/alliance/widgets/timeline.dart';

class TabsContent extends StatefulWidget {
  TabsContent({Key key}) : super(key: key);

  @override
  _TabsContentState createState() => _TabsContentState();
}

class _TabsContentState extends State<TabsContent> {
  PageController _pageController;
  int actIndex = 0;
  @override
  void initState() {
    super.initState();
    _pageController = PageController(keepPage: true);
    _pageController.addListener(() {
      setState(() {
        // _currPageValue = _pageController.page;
      });
    });
  }

  onIndexChange(int index) {
    actIndex = index;
    _pageController.animateToPage(index,
        duration: Duration(milliseconds: 16), curve: Curves.elasticIn);
    setState(() {});
  }

  onPageChanged(int index) {
    actIndex = index;
    setState(() {});
  }

  Widget build(BuildContext context) {
    return Container(
        // padding:
        //     EdgeInsets.only(top: MediaQueryData.fromWindow(window).padding.top),
        child: Column(
      children: [
        Head(),
        TabsBtn(
          onChange: onIndexChange,
          actIndex: actIndex,
        ),
        Container(
          height: 10,
          color: rgba(249, 249, 249, 1),
        ),
        Expanded(
          child: PageView(
            onPageChanged: onPageChanged,
            controller: _pageController,
            children: [GroupInfoPage(), TimeLineList(), ProjectList()],
          ),
        ),
      ],
    ));
  }
}
